package kg.aibek.projecteuler.p10;

public class Problem17 {
	public void solve() {
		int c = 0;
		for (int i = 1; i <= 1000; i++) {
			c += count(i);
		}
		System.out.println(c);
	}

	private int count(int i) {
		if (i < 10) {
			switch (i) {
			case 0:
				return 0;
			case 1:
				return 3;
			case 2:
				return 3;
			case 3:
				return 5;
			case 4:
				return 4;
			case 5:
				return 4;
			case 6:
				return 3;
			case 7:
				return 5;
			case 8:
				return 5;
			case 9:
				return 4;
			default:
				return 0;
			}
		} else if (i < 20) {
			switch (i) {
			case 10:
				return 3;
			case 11:
				return 6;
			case 12:
				return 6;
			case 13:
				return 8;
			case 14:
				return 8;
			case 15:
				return 7;
			case 16:
				return 7;
			case 17:
				return 9;
			case 18:
				return 8;
			case 19:
				return 8;
			default:
				return 0;
			}
		} else if (i < 100) {
			int a = i / 10;
			switch (a) {
			case 2:
				return 6 + count(i % 10);
			case 3:
				return 6 + count(i % 10);
			case 4:
				return 5 + count(i % 10);
			case 5:
				return 5 + count(i % 10);
			case 6:
				return 5 + count(i % 10);
			case 7:
				return 7 + count(i % 10);
			case 8:
				return 6 + count(i % 10);
			case 9:
				return 6 + count(i % 10);
			default:
				return 0;
			}
		} else if (i < 1000) {
			int c = 7;
			if (i % 100 != 0)
				c += 3;
			c += count(i / 100);
			c += count(i % 100);
			return c;
		} else {
			int c = 8;
			c += count(i / 1000);
			c += count(i % 1000);
			return c;
		}
	}

	public static void main(String[] args) {
		Problem17 p = new Problem17();
		p.solve();
	}
}
